package version1_4;

import version1_1.User;

import java.util.concurrent.Callable;

/**
 * @program:IntelliJ IDEA
 * @Description:电脑类
 * @author:Mr.CheCheHuiBujianO
 * @data: 2022/7/12 15:16
 */
public class Computer extends User implements Callable<String> {

    private String[] computerName = new String[]{"小黄","小绿","小紫","小白"};

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName() {
        int nameResult = (int) (Math.random()*10000%3);
        String computerName = this.computerName[nameResult];
        System.out.println("当前你在和"+computerName+"进行对战");
        this.name = computerName;
    }

    @Override
    public String getGesture() {
        return this.gesture;
    }

    @Override
    public void setGesture() {
        int randomGestureNumber = (int) (Math.random()*10000%2);
        this.gesture = this.GestureGroup[randomGestureNumber];
    }

    /**
     * Computes a result, or throws an exception if unable to do so.
     *
     * @return computed result
     * @throws Exception if unable to compute a result
     */
    @Override
    public String call() throws Exception {
        //先设置我们电脑的名字
        Computer computer = new Computer();
//        computer.setName();
        computer.setGesture();//设置电脑出的手势
        System.out.println(Thread.currentThread().getName());
        return computer.getGesture();//将我们电脑手势进行返回
    }
}
